<?php
/*
 * Author:  Somnath Shinde- soma.shinde@gmail.com Mobile No:- 9423792564
 * 
 * Create Date: 
 * 
 * Version of MYSQL_to_PHP: 1.1
 * 
 * Ranzani( YZ'S );
 * 
 */
//require_once 'classes/DataBaseMysql.class.php';

Class BaseBloods {

	protected $m_intId;
	protected $m_intPatientId;
	protected $m_intCasePaperId;
	protected $m_intDoctorId;
	protected $m_intChargeId;
	protected $m_strRemark;
	protected $m_strDateOfExamination;
	protected $m_strHb;
	protected $m_strTotalWbcs;
	protected $m_strDifferentialCount;
	protected $m_strPolymorphs;
	protected $m_strEosinophils;
	protected $m_strBasophi;
	protected $m_strLymphocytes;
	protected $m_strMonocytes;
	protected $m_strMalarialParasite;
	protected $m_strEsrInListHour;
	protected $m_strSpecialFindings;
	protected $m_strBt;
	protected $m_strCt;
	protected $m_strGramsMm;
	protected $m_strEximationCount;
	protected $m_intCreatedBy;
	protected $m_strCreatedOn;
	protected $m_intUpdatedBy;
	protected $m_strUpdatedOn;
	protected $connection;

	public function  __construct() {
		if( true == isset( $_SERVER['connection'] ) ) {
			$this->connection = $_SERVER['connection'];
		}
	}

	
	/*******************************************************************************************
	******************************** get Functions *********************************************
	*******************************************************************************************/

	public function getId(){
		return $this->m_intId;
	}

	public function getPatientId(){
		return $this->m_intPatientId;
	}

	public function getCasePaperId(){
		return $this->m_intCasePaperId;
	}

	public function getDoctorId(){
		return $this->m_intDoctorId;
	}

	public function getChargeId(){
		return $this->m_intChargeId;
	}

	public function getRemark(){
		return $this->m_strRemark;
	}

	public function getDateOfExamination(){
		return $this->m_strDateOfExamination;
	}

	public function getHb(){
		return $this->m_strHb;
	}

	public function getTotalWbcs(){
		return $this->m_strTotalWbcs;
	}

	public function getDifferentialCount(){
		return $this->m_strDifferentialCount;
	}

	public function getPolymorphs(){
		return $this->m_strPolymorphs;
	}

	public function getEosinophils(){
		return $this->m_strEosinophils;
	}

	public function getBasophi(){
		return $this->m_strBasophi;
	}

	public function getLymphocytes(){
		return $this->m_strLymphocytes;
	}

	public function getMonocytes(){
		return $this->m_strMonocytes;
	}

	public function getMalarialParasite(){
		return $this->m_strMalarialParasite;
	}

	public function getEsrInListHour(){
		return $this->m_strEsrInListHour;
	}

	public function getSpecialFindings(){
		return $this->m_strSpecialFindings;
	}

	public function getBt(){
		return $this->m_strBt;
	}

	public function getCt(){
		return $this->m_strCt;
	}

	public function getGramsMm(){
		return $this->m_strGramsMm;
	}

	public function getEximationCount(){
		return $this->m_strEximationCount;
	}

	public function getCreatedBy(){
		return $this->m_intCreatedBy;
	}

	public function getCreatedOn(){
		return $this->m_strCreatedOn;
	}

	public function getUpdatedBy(){
		return $this->m_intUpdatedBy;
	}

	public function getUpdatedOn(){
		return $this->m_strUpdatedOn;
	}
	
	/*******************************************************************************************
	********************************* set Functions ********************************************
	*******************************************************************************************/

	public function setId( $Id ){
		$this->m_intId = $Id;
	}

	public function setPatientId( $PatientId ){
		$this->m_intPatientId = $PatientId;
	}

	public function setCasePaperId( $CasePaperId ){
		$this->m_intCasePaperId = $CasePaperId;
	}

	public function setDoctorId( $DoctorId ){
		$this->m_intDoctorId = $DoctorId;
	}

	public function setChargeId( $ChargeId ){
		$this->m_intChargeId = $ChargeId;
	}

	public function setRemark( $Remark ){
		$this->m_strRemark = $Remark;
	}

	public function setDateOfExamination( $DateOfExamination ){
		$this->m_strDateOfExamination = $DateOfExamination;
	}

	public function setHb( $Hb ){
		$this->m_strHb = $Hb;
	}

	public function setTotalWbcs( $TotalWbcs ){
		$this->m_strTotalWbcs = $TotalWbcs;
	}

	public function setDifferentialCount( $DifferentialCount ){
		$this->m_strDifferentialCount = $DifferentialCount;
	}

	public function setPolymorphs( $Polymorphs ){
		$this->m_strPolymorphs = $Polymorphs;
	}

	public function setEosinophils( $Eosinophils ){
		$this->m_strEosinophils = $Eosinophils;
	}

	public function setBasophi( $Basophi ){
		$this->m_strBasophi = $Basophi;
	}

	public function setLymphocytes( $Lymphocytes ){
		$this->m_strLymphocytes = $Lymphocytes;
	}

	public function setMonocytes( $Monocytes ){
		$this->m_strMonocytes = $Monocytes;
	}

	public function setMalarialParasite( $MalarialParasite ){
		$this->m_strMalarialParasite = $MalarialParasite;
	}

	public function setEsrInListHour( $EsrInListHour ){
		$this->m_strEsrInListHour = $EsrInListHour;
	}

	public function setSpecialFindings( $SpecialFindings ){
		$this->m_strSpecialFindings = $SpecialFindings;
	}

	public function setBt( $Bt ){
		$this->m_strBt = $Bt;
	}

	public function setCt( $Ct ){
		$this->m_strCt = $Ct;
	}

	public function setGramsMm( $GramsMm ){
		$this->m_strGramsMm = $GramsMm;
	}

	public function setEximationCount( $EximationCount ){
		$this->m_strEximationCount = $EximationCount;
	}

	public function setCreatedBy( $CreatedBy ){
		$this->m_intCreatedBy = $CreatedBy;
	}

	public function setCreatedOn( $CreatedOn ){
		$this->m_strCreatedOn = $CreatedOn;
	}

	public function setUpdatedBy( $UpdatedBy ){
		$this->m_intUpdatedBy = $UpdatedBy;
	}

	public function setUpdatedOn( $UpdatedOn ){
		$this->m_strUpdatedOn = $UpdatedOn;
	}
	
	/*******************************************************************************************
	********************************* Insert Functions ********************************************
	*******************************************************************************************/

	public function insert(){
		return $this->connection->RunQuery( "Insert into BLOODS (patient_id, case_paper_id, doctor_id, charge_id, remark, date_of_examination, hb, total_wbcs, differential_count, polymorphs, eosinophils, basophi, lymphocytes, monocytes, malarial_parasite, esr_in_list_hour, special_findings, bt, ct, grams_mm, eximation_count, created_by, created_on, updated_by, updated_on) values (" . $this->getPatientId() . ", " . $this->getCasePaperId() . ", " . $this->getDoctorId() . ", " . $this->getChargeId() . ", '" . $this->getRemark() . "', '" . $this->getDateOfExamination() . "', '" . $this->getHb() . "', '" . $this->getTotalWbcs() . "', '" . $this->getDifferentialCount() . "', '" . $this->getPolymorphs() . "', '" . $this->getEosinophils() . "', '" . $this->getBasophi() . "', '" . $this->getLymphocytes() . "', '" . $this->getMonocytes() . "', '" . $this->getMalarialParasite() . "', '" . $this->getEsrInListHour() . "', '" . $this->getSpecialFindings() . "', '" . $this->getBt() . "', '" . $this->getCt() . "', '" . $this->getGramsMm() . "', '" . $this->getEximationCount() . "', " . $this->getCreatedBy() . ", now() , " . $this->getUpdatedBy() . ", NULL )");
	}
	
	/*******************************************************************************************
	********************************* Update Functions ********************************************
	*******************************************************************************************/

	public function update(){
		return $this->connection->RunQuery( "UPDATE BLOODS set  case_paper_id= " . $this->getCasePaperId() . ", doctor_id= " . $this->getDoctorId() . ", charge_id= " . $this->getChargeId() . ", remark= '" . $this->getRemark() . "', date_of_examination= '" . $this->getDateOfExamination() . "', hb= '" . $this->getHb() . "', total_wbcs= '" . $this->getTotalWbcs() . "', differential_count= '" . $this->getDifferentialCount() . "', polymorphs= '" . $this->getPolymorphs() . "', eosinophils= '" . $this->getEosinophils() . "', basophi= '" . $this->getBasophi() . "', lymphocytes= '" . $this->getLymphocytes() . "', monocytes= '" . $this->getMonocytes() . "', malarial_parasite= '" . $this->getMalarialParasite() . "', esr_in_list_hour= '" . $this->getEsrInListHour() . "', special_findings= '" . $this->getSpecialFindings() . "', bt= '" . $this->getBt() . "', ct= '" . $this->getCt() . "', grams_mm= '" . $this->getGramsMm() . "', eximation_count= '" . $this->getEximationCount() . "', created_by= " . $this->getCreatedBy() . ", updated_by= " . $this->getUpdatedBy() . ",updated_on = now()  where id =" . $this->getId() );
	}
	
	/*******************************************************************************************
	********************************* Delete Functions ********************************************
	*******************************************************************************************/

	public function Delete($intId ) {
		$this->connection->RunQuery( "DELETE FROM bloods WHERE id = $intId");
	}

	public function fetchNextId() {
		$result = $this->connection->RunQuery( "SELECT AUTO_INCREMENT as id FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '" . DB_DATABASE . "' AND TABLE_NAME = 'bloods'" );
		if( false == $result ) return NULL;

		while( $row = $result->fetch_array( MYSQLI_ASSOC ) ) {
			$this->id = $row["id"];
		}

		return $this->id;
	}

}